package org.twndmv.bo;

import java.util.HashMap;
import java.util.Map;

import org.twndmv.exception.NoSuchStateException;

public enum State {
	
	AL("ALABAMA"),AK("ALASKA"),AZ("ARIZONA"),AR("ARKANSAS"),CA("CALIFORNIA"),CO("COLORADO"),CT("CONNECTICUT"),DE("DELAWARE"),FL("FLORIDA"),
	GA("GEORGIA"),HI("HAWAII"),ID("IDAHO"),IL("ILLINOIS"),IN("INDIANA"),IA("IOWA"),KS("KANSAS"),KY("KENTUCKY"),LA("LOUISIANA"),ME("MAINE"),
	MD("MARYLAND"),MA("MASSACHUSETTS"),MI("MICHIGAN"),MN("MINNESOTA"),MS("MISSISSIPPI"),MO("MISSOURI"),MT("MONTANA"),NE("NEBRASKA"),NV("NEVADA"),NH("NEW HAMPSHIRE"),
	NJ("NEW JERSEY"),NM("NEW MEXICO"),NY("NEW YORK"),NC("NORTH CAROLINA"),ND("NORTH DAKOTA"),OH("OHIO"),OK("OKLAHOMA"),OR("OREGON"),PA("PENNSYLVANIA"),RI("RHODE ISLAND"),
	SC("SOUTH CAROLINA"),SD("SOUTH DAKOTA"),TN("TENNESSEE"),TX("TEXAS"),UT("UTAH"),VT("VERMONT"),VA("VIRGINIA"),WA("WASHINGTON"),WV("WEST VIRGINIA"),WI("WISCONSIN"),WY("WYOMING");
	
	private static final Map<String, State> map =
    new HashMap<String, State>();

  static {
   for (State state : State.values()) {
     map.put(state.name, state);
   }
   }
  
  private State(String name) {
		this.name = name;
	}
	
	private String name;
	
	public String getName() {
		return name;
	}
	
	public static State translate(String arg) throws NoSuchStateException { 
		State st = map.get(arg);
		if(st != null) {
			return st;
		} else {
			throw new NoSuchStateException("Not allowed state: " + arg);
		}
		
	}
}
